//Write by oshogbo//vx
//23.07.2011
//http://code.google.com/p/streamobs

import javax.swing.*;
import java.awt.*;

class ServerType extends JComboBox
{
  private static final long serialVersionUID = 1L;
  
  private static final String[] serverTypes = {
    "JustinTV", "Ustream Channel", "Livestream"
  };

  public ServerType()
  {
    super(serverTypes);
  }

  public ChannelType getSelectedItem(String name)
  {
    switch( getNumberOfSelectedItem() )
    {
      case 0: return new JustinTV(name);
      case 1: return new Ustream(name);
      case 2: return new LiveStream(name);
    }

    return null;
  }

  public int getNumberOfSelectedItem()
  {
    int hashCode = ((String)super.getSelectedItem()).hashCode();
   
    for(int i = 0; i < serverTypes.length; i++) 
      if( hashCode == serverTypes[i].hashCode() ) 
	return i;

    return -1;
  }

  public void setSelectedItem( int k )
  {
    super.setSelectedItem( serverTypes[ k ] );
  }
}
